IJResultFiles1 <- list.files(path = "[path]/plate4", pattern = "*.csv", all.files = TRUE, full.names = TRUE)

features1 <- NULL

for (x in IJResultFiles1) {
	OneFeatureFile <- read.delim(x, header=T) 
	features1 <- rbind(features1, OneFeatureFile)
}


IJResultFiles2 <- list.files(path = "[path]/plate5", pattern = "*.csv", all.files = TRUE, full.names = TRUE)

features2 <- NULL

for (x in IJResultFiles2) {
	OneFeatureFile <- read.delim(x, header=T) 
	features2 <- rbind(features2, OneFeatureFile)
}

infectedMeanIntWT <- features1[features1$cellinfected==1,]
NONinfectedMeanIntWT <- features1[features1$cellinfected==0,]

infectedMeanIntSifa <- features2[features2$cellinfected==1,]
NONinfectedMeanIntSifa <- features2[features2$cellinfected==0,]

#- save values

output <- as.data.frame(infectedMeanIntWT$ERmeanint)
write.table(output, file = "[path]/plate4_infected_cell_mean_ER_intensity_WT.csv", sep = "\t", quote = FALSE, row.names = FALSE, col.names = FALSE) 

output <- as.data.frame(NONinfectedMeanIntWT$ERmeanint)
write.table(output, file = "[path]/plate4_NONinfected_cell_mean_ER_intensity_WT.csv", sep = "\t", quote = FALSE, row.names = FALSE, col.names = FALSE) 

output <- as.data.frame(infectedMeanIntSifa$ERmeanint)
write.table(output, file = "[path]/plate5_infected_cell_mean_ER_intensity_sifA.csv", sep = "\t", quote = FALSE, row.names = FALSE, col.names = FALSE) 

output <- as.data.frame(NONinfectedMeanIntSifa$ERmeanint)
write.table(output, file = "[path]/plate5_NONinfected_cell_mean_ER_intensity_sifA.csv", sep = "\t", quote = FALSE, row.names = FALSE, col.names = FALSE) 
